package com.atguigu.gmall.realtime.function;

import com.atguigu.gmall.realtime.util.IkUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.util.Set;

/**
 * @Author lizhenchao@atguigu.cn
 * @Date 2021/11/5 10:18
 */
@FunctionHint(output = @DataTypeHint("row<word string>"))
public class IkAnalyzer extends TableFunction<Row> {
    public void eval(String keyword){
        //把keyword切开
       Set<String> words =  IkUtil.split(keyword);
    
        for (String word : words) {
            collect(Row.of(word));  // 每调用一次就多一行
        }
    }
}
